{extend name='./content'}

{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
    <div class="shop_name">商户数<span>  {user_count}  </span>人</div>
</div>
{/block}

{block name="content"}

<!-- 表单搜索 开始 -->
<form class="layui-form  form-search" action="__SELF__" onsubmit="return false" method="get">

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">搜索字段</label>
        <div class="layui-input-inline">
            <select class="layui-input" name="field">
                <option value="1" {if $Think.get.field=='1'}selected{/if}>商户ID</option>
                <option value="2" {if $Think.get.field=='2'}selected{/if}>账号</option>
                <option value="3" {if $Think.get.field=='3'}selected{/if}>店铺名</option>
                <option value="4" {if $Think.get.field=='4'}selected{/if}>手机号码</option>
                <option value="5" {if $Think.get.field=='5'}selected{/if}>QQ</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">关键词</label>
        <div class="layui-input-inline">
            <input name="keyword" value="{$Think.get.keyword|default=''}" placeholder="请输入关键词" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <select class="layui-input" name="status">
                <option value="" {if $Think.get.status==''}selected{/if}>全部</option>
                <option value="0" {if $Think.get.status==='0'}selected{/if}>未审核</option>
                <option value="1" {if $Think.get.status=='1'}selected{/if}>已审核</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item layui-inline">
        <label class="layui-form-label">注册时间</label>
        <div class="layui-input-inline">
            <input name="date_range" id="date_range" value="{:urldecode($Think.get.date_range)}" placeholder="请选择时间范围" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item layui-inline">
        <button type="submit" class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
    </div>
</form>
<!-- 表单搜索 结束 -->


<form onsubmit="return false;" data-auto="true" method="post">
    <input type="hidden" value="resort" name="action"/>
    <table class="layui-table" lay-skin="line" lay-size="sm" align="right">
        <thead>
        <tr>
            <th class='text-center'>编号</th>
            <th class="text-center">头像</th>  
            <th>昵称</th> 
            <th class='text-center'>注册时间</th>
			<th class='text-center'>登录时间</th>
			<th class='text-center'>注册IP</th>
			<th>类型</th>
            <th>状态</th>			
            <th class='text-center'>操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $data as $v}
        <tr>
            <td class='text-center'>{$v.id}</td>
            <td class="text-center"><img src="{$v.tx}" alt="{v.name}" class="user-avatar"></td>
            <td>{$v.name}</td>
            <td class='text-center'>{$v.sj}</td>
            <td class='text-center'>{$v.login}</td>
			<td class='text-center'>{$v.uip}</td>
			<td>{$v.type}</td>
            <td>
                {if $v.status==2}
                <a style="color:red" data-tips="确定取消冻结吗？ " data-update="{v.id}" data-field='status' data-value='0' data-action='{:url("change_freeze_status")}'
                   href="javascript:void(0)">已冻结</a>
                {else/}
                <a style="color:green" data-tips="确定冻结吗？" data-update="{v.id}" data-field='status' data-value='1' data-action='{:url("change_freeze_status")}'
                   href="javascript:void(0)">正常</a>
                {/if}
            </td>			
			<td class='text-center nowrap'>
                <a data-title="后台"  href="{:url('login')}?bh={$v.ubh}" target="_blank">登录</a>
				<a data-title="删除"  href="javascript:void(0)" onclick="user_del(this,'{v.bh}')">删除</a>
			</td>
        </tr>
        {/foreach}
        </tbody>
    </table>
</form>
{$page}
<script>
    layui.use('form', function(){
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        form.render();
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //日期范围
        laydate.render({
            elem: '#date_range',
            range: true
        });
    });
    /*用户-删除*/
    function user_del(obj, bh) {
        layer.confirm('确认要删除这个用户吗？', function (index) {
            $.ajax({
                url:"/manage/user/del",
                type:'post',
                data:'bh='+bh,
                success:function(res){
                    if(res.code == 1){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    } else {
                        layer.msg('删除失败!',{icon:1,time:1000});
                    }
                }
            });
        });
    }
    /*用户-修改收款信息*/
    function allow_update(obj, id) {
        layer.confirm('允许用户修改收款信息？', function (index) {
            $.ajax({
                url:"{:url('allow_update')}",
                type:'post',
                data:'id='+id,
                success:function(res){
                    if(res.code == 1){
                        layer.msg('设置成功!',{icon:1,time:1000});
                    } else {
                        layer.msg(res.msg,{icon:2,time:1000});
                    }
                }
            });
        });
    }
    $('img').on('click', function () {
		layer.photos({
			photos: '.layui-table',
			shadeClose: false,
			closeBtn: 2,
			anim: 0
		});
	})
</script>
{/block}
